<?php 
error_reporting(0);
require_once ('config.php'); 
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>添加项目</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="global.css" type="text/css"/>
<script src="laydate/laydate.js"></script>






<style type="text/css">
.message-box{
width:88%;
margin-top:6%;
}
body{
padding-bottom:20px;
}
label{
display:block;
text-align:center;
font-size:14px;
padding:5px;
margin:auto;
width:60px;
}
hr{
margin:8px;
}
.title-img{
height:25px;
width:auto;
margin-bottom:-10px;
}
.ex-btn{
display:inline-block;
padding:8px;
}
.container{
display:block;
width:100%;
}
.message-box .btn{
float:none;
margin:auto;
margin-top:15px;
margin-bottom:10px;
}
a{
color:#fe6565;
display:inline-block;
position:static;
}
#wexin-login-btn{
margin-bottom:10px;
}
.message-box .content{
max-height:none;
margin-bottom:5px;
margin-top:5px;
}
.circle-icon{
width:18px;
height:18px;
border-radius:9px;
background-color:#F0BEE0;
}
.circle-icon span{
color:white;
}
.hint-box{
font-size:small;
}
input{
text-align:center;
}
p{
font-size:14px;
}
a{
font-size:14px;
}
#area-select{
cursor:pointer;
width: 186px;
text-align: center;
color: #444;
background-color: #fff;
background-size: auto 15px;
padding: 8px;
border-radius: 8px;
border: 1px solid #ddd;
}
</style>
<?php
  $sql1="select * from d_user where d_user_name='".$_SESSION['d_user']."'";
  $rs1=mysql_fetch_array(mysql_query($sql1));
  //echo $rs1['d_user_id'];
  //echo $rs1['d_user_money']."</br>";

if($_POST["submit"])

{ 
  if($_POST['d_pro_money']>$rs1['d_user_money'])
  {
    echo "<script>alert('穷光蛋！');location='member.php';</script>";
  }
  else
  { 
    $d1=strtotime($_POST['d_pro_end']);
    $d2=strtotime($_POST['d_pro_start']);
    $cycle=round(($d1-$d2)/3600/24);
    $residue=$rs1['d_user_money']-$_POST['d_pro_money'];
    mysql_query($sql2="update d_user set d_user_money='$residue' where d_user_name='".$_SESSION['d_user']."'");
    $sql="insert into d_programe values('','".$_POST['d_pro_name']."','".$_POST['d_pro_start']."','".$_POST['d_pro_end']."','".$cycle."','','".$_POST['d_pro_money']."','".$rs1['d_user_id']."','".$_POST['d_friend_id']."')";
    $result=mysql_query($sql)or die(mysql_error());
  if($result)
  echo "<script>alert('OK');location='member.php';</script>";
  }
  
}
  
?>
</head>
<body>

<?php
function test()
{
  echo "string";
}
?>

<div id="login-box" class="message-box" >
<header class="fruit-bg-header"></header>
<div class="content" >
	<section class="container" >
		<form id="theForm" name="theForm" method="post" action="" onSubmit="return chk(this)" runat="server" style="margin-bottom:0px;">
			<label >我要</label>
			<input name="d_pro_name" type="text" id="d_pro_name" placeholder="我要……">
      		<label >开始时间</label>
      		<input name="d_pro_start" type="text" id="d_pro_start" onclick="laydate()" readonly="readonly" placeholder="XXXX-XX-XX">
			    <label >结束时间</label>
			    <input name="d_pro_end" type="text" id="d_pro_end" onclick="laydate()" readonly="readonly" placeholder="XXXX-XX-XX">
			    <!--<label >持续时间</label>
			    <input name="d_pro_cycle" type="text" id="d_pro_cycle" placeholder="请输入持续天数">-->
      		<label >保证金</label>
      		<input name="d_pro_money" type="text" id="d_pro_money" placeholder="请输入保证金">
      		<label >监督人</label>
      		<input name="d_friend_id" type="text" id="d_friend_id" placeholder="请输入好友ID" ></br>
          

      		<input name="submit" type="submit" value="坚持开始" class="btn" style="font-family: 微软雅黑"/>
		</form>
	<section class="container" >
</div>
</div>

<footer id="footer-bar" >
<div class="head-border" ></div>
<div class="btn-wrapper" >
<div class="btn-list" >
<li id="home-btn" data-id="home" ><a href='member.php'><img src="./img/home-icon.png" class="icon"/>个人中心</a></li>
<li id="home-btn" data-id="home" ><a href='my_friends.php'><img src="./img/order-icon.png" class="icon"/>我的好友</a></li>
<li id="home-btn" data-id="home" ><a href='my_programe.php'><img src="./img/order-icon.png" class="icon"/>我的项目</a></li>
<li id="home-btn" data-id="home" ><a href='my_supervise.php'><img src="./img/order-icon.png" class="icon"/>监督项目</a></li>

</div>
</div>
</footer>
</body>
</html>
